package com.yuwei.mine

import com.yuwei.common.mvi.BaseViewModel
import com.yuwei.database.RoomDBUtils.getFavVideoDao
import com.yuwei.database.RoomDBUtils.getGoodsDao
import com.yuwei.database.RoomDBUtils.getOrderDao

class MineViewModel: BaseViewModel<MineApiService, MineIntent>() {
    override fun handleIntent(intent: MineIntent) {
        when(intent){
            is MineIntent.getHistory -> {
                roomRequest({getGoodsDao().getAll()},"getHistory")
            }
            is MineIntent.getOrder->{
                roomRequest({getOrderDao().getAll()},"getOrder")
            }
            is MineIntent.getStatus->{
                roomRequest({getOrderDao().getByStatus(intent.status)},"getStatus")
            }
            is MineIntent.getFavAll->{
                roomRequest({ getFavVideoDao().getAll()},"getFavAll")
            }
        }
    }

}